package com.justcan.demo.cartoon.utils.anim;

import android.content.Context;
import android.graphics.Canvas;
import android.view.View;

/**
 * 动画绘制基础接口
 * @author zhanghuijun
 *
 */
public class AnimObject {

	/**
	 * 是否需要绘制
	 */
	private boolean mIsNeedDraw = true;
	/**
	 * 父AnimObject
	 */
	private AnimObjectGroup mParent = null;
	/**
	 * 根AnimView
	 */
	private View mRootAnimView = null;
	/**
	 * 整个动画场景的宽高
	 */
	private int mSceneWidth = 0;
	private int mSceneHeight = 0;
	/**
	 * Context
	 */
	private Context mContext = null;

	public AnimObject(View mRootAnimView, Context mContext) {
		this.mRootAnimView = mRootAnimView;
		this.mContext = mContext;
		mSceneWidth = ((IAnimView) mRootAnimView).getAnimSceneWidth();
		mSceneHeight = ((IAnimView) mRootAnimView).getAnimSceneHeight();
	}

	/**
	 * 绘制
	 */
	public void draw(Canvas canvas, int sceneWidth, int sceneHeight) {
	}

	/**
	 * 逻辑
	 */
	public void logic(long animTime, long deltaTime) {
	}

	/**
	 * 动画场景大小改变
	 */
	public void onSizeChange(int w, int h) {
		mSceneWidth = w;
		mSceneHeight = h;
	}

	/**
	 * 是否需要绘制
	 */
	public boolean isNeedDraw() {
		return mIsNeedDraw;
	}

	public void setIsNeedDraw(boolean mIsNeedDraw) {
		this.mIsNeedDraw = mIsNeedDraw;
	}

	public AnimObjectGroup getParent() {
		return mParent;
	}

	public void setParent(AnimObjectGroup mParent) {
		this.mParent = mParent;
	}

	public View getRootAnimView() {
		return mRootAnimView;
	}

	public int getAnimSceneWidth() {
		return mSceneWidth;
	}

	public int getAnimSceneHeight() {
		return mSceneHeight;
	}

	public Context getContext() {
		return mContext;
	}
}
